package at.codebase.db.entities;

import at.codebase.db.entities.EItemFeedback.EItemFeedbackRating;

import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;

@Entity
public class EExternalItemFeedback {

	@Id
	private Long itemFeedbackId;
	private Long localUserId;
	private String localUsername;
	@Index
	private Long partnerId;
	@Index
	private String itemId;
	private EItemFeedbackRating feedbackRating;
	private String feedbackContent;
	private Long timeCreate;

	public Long getId() {
		return itemFeedbackId;
	}

	public void setId(Long id) {
		this.itemFeedbackId = id;
	}

	public String getItemId() {
		return itemId;
	}

	public void setItem(String itemId) {
		this.itemId = itemId;
	}

	public String getFeedbackContent() {
		return feedbackContent;
	}

	public void setFeedbackContent(String feedbackContent) {
		this.feedbackContent = feedbackContent;
	}

	public double getFeedbackRatingValue() {
		if (feedbackRating != null) {
			if (feedbackRating.equals(EItemFeedbackRating.RUBY_1)) {
				return 1.0d;
			} else if (feedbackRating.equals(EItemFeedbackRating.RUBY_2)) {
				return 2.0d;
			} else if (feedbackRating.equals(EItemFeedbackRating.RUBY_3)) {
				return 3.0d;
			} else if (feedbackRating.equals(EItemFeedbackRating.RUBY_4)) {
				return 4.0d;
			} else if (feedbackRating.equals(EItemFeedbackRating.RUBY_5)) {
				return 5.0d;
			} else {
				return -1.0d;
			}
		}
		return -1.0d;
	}

	public void setFeedbackRating(EItemFeedbackRating feedbackRating) {
		this.feedbackRating = feedbackRating;
	}

	public EItemFeedbackRating getFeedbackRating() {
		return feedbackRating;
	}

	public Long getItemFeedbackId() {
		return itemFeedbackId;
	}

	public void setItemFeedbackId(Long itemFeedbackId) {
		this.itemFeedbackId = itemFeedbackId;
	}

	public Long getLocalUserId() {
		return localUserId;
	}

	public void setLocalUserId(Long localUserId) {
		this.localUserId = localUserId;
	}

	public Long getPartnerId() {
		return partnerId;
	}

	public void setPartnerId(Long partnerId) {
		this.partnerId = partnerId;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public static EExternalItemFeedback create(String itemId2, Long id,
			EItemFeedbackRating feedbackRating2,
			String feedbackText) {
		EExternalItemFeedback fb = new EExternalItemFeedback();
		fb.setItemId(itemId2);
		fb.setId(id);
		fb.setFeedbackRating(feedbackRating2);
		fb.setFeedbackContent(feedbackText);
		fb.timeCreate = new Long(System.currentTimeMillis());
		return fb;
	}

	public Long getTimeCreate() {
		return timeCreate;
	}

	public String getLocalUsername() {
		return localUsername;
	}

	public void setLocalUsername(String localUsername) {
		this.localUsername = localUsername;
	}

	public void setTimeCreate(Long timeCreate) {
		this.timeCreate = timeCreate;
	}

}
